//
//  SearchCollectionViewCell.swift
//  TianTianBiTing
//
//  Created by Gox mac 2 on 2019/2/26.
//  Copyright © 2019 Gox_WallyDiao. All rights reserved.
//

import UIKit

class SearchCollectionViewCell: UICollectionViewCell {
    var titleStr:String?
    var titleBtn:UILabel = {
        let btn = UILabel.init()
        btn.backgroundColor = RGB_Same(240)
        btn.layer.cornerRadius = 14
        btn.textAlignment = .center
        btn.layer.masksToBounds = true
        btn.textColor = RGB_Same(53)
        btn.font = Font_Medium(14)
        return btn
    }()
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        setUI()
    }
    
    func setUI() {
        self.contentView.addSubview(self.titleBtn)
        
    }
    
    func setHeight(str:String) -> CGFloat {
        let num = str.count
        let count = 30 + 15 * num
        return CGFloat(count)
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
        
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        let width = setHeight(str: self.titleStr ?? "")
        self.titleBtn.frame = FRAME_CGFloat(0, 0, width, 28)
    }
}
